<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Alternatives extends MY_Controller {

	function __construct() {
		parent::__construct();
	}
	
	public function index($catid='')
	{
		if ($this->isSessionActive()) {
			
			$this->load->model('offer_model');
			$this->load->model('alternatives_model');
			
			$data['user'] = $this->fb_id;
			$data['title'] = 'Alternatives';
			$data['content_view'] = 'alternatives_view';
			$data['stylesheets'] = array('alternatives', 'paginate-style');
			$data['javascripts'] = array('alternatives', 'paginate', 'alternatives_paginate');
			
			if ($catid)
				$data['selectedcategory'] = $catid;
			$data['category'] = $this->offer_model->get_category();
			$data['location'] = $this->alternatives_model->get_alternative_location();
			$data['alternative'] = $this->alternatives_model->get_alternative($catid);
			$data['category_tag'] = $this->alternatives_model->get_alternative_category_tag();
			$data['location_tag'] = $this->alternatives_model->get_alternative_location_tag();
			
			$message = "This page is still Under Construction. Sorry!";
			$this->add_status_message($message);
			
    		$this->load_template_view($data, TRUE);
		}
	}
	
	function sort($category, $location){
		$this->load->model("Alternatives_model");
		$data = $this->Alternatives_model->sort($category, $location);
		echo json_encode($data);
	}
	
}